import pyperclip
import pyautogui

pyautogui.PAUSE = 1 # 调用在执行动作后暂停的秒数，只能在执行一些pyautogui动作后才能使用，建议用time.sleep

file_1 = open("textfile.txt","w")
def findWindow():
    windows = pyautogui.getWindowsWithTitle('天涯明月刀')
    if len(windows) == 0:
        raise Exception("窗口未找到")
    return windows[0]


def clickAvatar():
    try:
        location = pyautogui.locateOnScreen('avatar.png')
        print(location) # Box(left=293, top=402, width=40, height=40)
        pyautogui.click(location)
        # pyautogui.click('avatar.png')  # 坐标用不到的话，可使用该命令
    except:
        print('头像未找到')

def clickSend():
     pyautogui.click('send.png')


def paste(content):
    pyperclip.copy(content)
    pyautogui.hotkey('ctrl', 'v')


if __name__ == '__main__':
    #gameWindow = findWindow()
    #print(gameWindow)
    #gameWindow.activate()  # 激活窗口,将窗口最前化
    #clickAvatar()
    #content = '你好'
    #paste(content)
    #clickSend()
    x1, y1 = (122, 58)
    file_1.write(str(x1)+ " " + str(y1))
    file_1.write("2548qweqwe5\n")
